package org.example.bean;

import jakarta.annotation.Resource;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.example.JavaBean.Student;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * @Auther:Liu
 * @Testname:SecurityStudentDetails
 * @Date:2025/9/17 10:05
 */
@Data
@NoArgsConstructor
public class SecurityStudentDetails implements UserDetails {
    //用户基本信息
    private Student student;
    //当前权限
    private List<GrantedAuthority> permissionValueList;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return permissionValueList;
    }

    @Override
    public String getPassword() {
        return student.getPassword();
    }

    @Override
    public String getUsername() {
        return student.getName();
    }

    //是否过期、可用、锁定
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
